import { createContext, useState } from 'react';
//1 创建createContext并导出，通过context.Provider提供数据。
export const context = createContext();

function AppProvider({ children }) {
  const [count, setCount] = useState(1);
  const plus = () => setCount(count + 1);
  return (
    <context.Provider value={{ title: '这是一个全局数据', count, plus }}>
      {children}
    </context.Provider>
  );
}

export default AppProvider;
